package com.hh.springboot.utils;

import java.util.List;

public class PageBean<T> {
    //当前页
    private int pageNo;
    //每页展示条数
    private int pageSize;
    //数据条数
    private int dataCount;
    //页码数
    private int pageCount;
    //数据
    private List<T> dataList;

    public PageBean() {
    }

    /**
     * pageCount无需提供
     */

    public PageBean(int dataCount, int pageSize) {
        this.dataCount = dataCount;
        pageCount = dataCount % pageSize == 0 ? dataCount / pageSize : dataCount / pageSize + 1;
        this.pageSize = pageSize;
    }

    public PageBean(int pageNo, int pageSize, int dataCount, List<T> dataList) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.dataCount = dataCount;
        pageCount = dataCount % pageSize == 0 ? dataCount / pageSize : dataCount / pageSize + 1;
        this.dataList = dataList;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getDataCount() {
        return dataCount;
    }

    public void setDataCount(int dataCount) {
        this.dataCount = dataCount;
        pageCount = dataCount % pageSize == 0 ? dataCount / pageSize : dataCount / pageSize + 1;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public List<T> getDataList() {
        return dataList;
    }

    public void setDataList(List<T> dataList) {
        this.dataList = dataList;
    }

    @Override
    public String toString() {
        return "PageBean{" +
                "pageNo=" + pageNo +
                ", pageSize=" + pageSize +
                ", dataCount=" + dataCount +
                ", pageCount=" + pageCount +
                ", dataList=" + dataList +
                '}';
    }
}
